// CppChatServerAdvanced.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Server.h"
#include <iostream>
#include "Client.h"
#include <windows.h>
#pragma comment(lib, "winmm.lib")

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{	
	PlaySound(LPCWSTR(101), NULL, SND_RESOURCE | SND_ASYNC);
	char input;
	while(true) {
		
		for(int i=0; i<8; i++) {
			cout << endl;
		}
		cout << "---------------------- Welcome to CppChatServerAdvanced ----------------------" << endl << endl;
		cout << "                           What do you want to run?                           " << endl;
		cout << "                                  1) Server" << endl;
		cout << "                                  2) Client" << endl;
		cout << "                                  x) Exit" << endl << endl;
		cout << "                                  >";
		cin.get(input);

		if(input == '1') {
			PlaySound(NULL,NULL,NULL);
			system("cls");
			Server server;
			server.start(4444);
			
		} else if(input == '2') {
			
			system("cls");
			for(int i=0; i<11; i++) {
				cout << endl;
			}
			cout << "----------------------------------- Client -----------------------------------" << endl << endl;;
			
			string nick;
			string ip;
			cout << "            Server IP (127.0.0.1 = localhost): ";
			cin >> ip;
			cout << "                                   Input nick: ";
			cin >> nick;
			system("cls");
			PlaySound(NULL,NULL,NULL);
			Client* client = new Client(nick,ip.c_str(),4444);
			
		} else if(input == 'x') {
			break;
		} else {	
			system("cls");
		}
	}	
	return 0;
}

